package com.example.demo.design.memo.two;

/**
 * @Author: liull
 * @Description:
 * @Date: Created in 17:08 2021/4/2
 * @Modified By:
 */
public class Client {
    public static void main(String[] args) {
        MementoCaretaker caretaker = new MementoCaretaker();
        Chessman chessman = new Chessman("车", 1, 1);
        display(chessman);
        caretaker.setMemento(chessman.save());
        chessman.setY(4);
        display(chessman);
        caretaker.setMemento(chessman.save());
        display(chessman);
        chessman.setX(5);
        display(chessman);
        System.out.println("***********悔棋*************");

        chessman.restore(caretaker.getMemento());
        display(chessman);
    }

    public static void display(Chessman chess) {
        System.out.println("棋子" + chess.getLabel() + "当前位置为：" + "第" + chess.getX() + "行" + "第" + chess.getY() + "列。");
    }
}
